import Vue from 'vue'

import Cookies from 'js-cookie'

import 'normalize.css/normalize.css' // a modern alternative to CSS resets

import Element from 'element-ui'
import './styles/element-variables.scss'

import '@/styles/index.scss' // global css

import App from './App'
import store from './store'
import router from './router'

import './icons' // icon
import './permission' // permission control
import './utils/error-log' // error log

import * as filters from './filters' // global filters

import permission from '@/directive/permission' //权限自定义指令
Vue.directive('permission', permission);

import VueQuillEditor from 'vue-quill-editor' //富文本
import 'quill/dist/quill.core.css'
import 'quill/dist/quill.snow.css'
import 'quill/dist/quill.bubble.css'
Vue.use(VueQuillEditor)

Vue.prototype.baseurl = window.config.VUE_FILE_OSS_PATH;

Vue.use(Element, {
	size: Cookies.get('size') || 'medium' // set element-ui default size
})
Vue.directive('img-error', {
  bind(el, binding) {
    // 绑定时的初始化逻辑，这里可以注册事件监听器等
    el.addEventListener('error', binding.value);
  },
  unbind(el, binding) {
    // 解绑时的清理逻辑，这里可以移除事件监听器等
    el.removeEventListener('error', binding.value);
  },
});

// register global utility filters
Object.keys(filters).forEach(key => {
	Vue.filter(key, filters[key])
})

Vue.config.productionTip = false

new Vue({
	el: '#app',
	router,
	store,
	render: h => h(App)
})